package java_1_12.book_management;

import java_1_12.book_management.book.BookList;
import java_1_12.book_management.user.AdminUser;
import java_1_12.book_management.user.NormalUser;
import java_1_12.book_management.user.User;

import java.util.Scanner;

//整个程序的入口
public class Main {
    private static Scanner scanner=new Scanner(System.in);
    public static void main(String[] args) {
        User user=login();
        BookList bookList=new BookList();
        while(true){
            int choice=user.menu();
            if(choice==-1){
                System.out.println("byebye");
                break;
            }
            user.doOperation(choice,bookList);
        }
    }
    //先登录-返回值是User-告诉程序到底登陆的是谁
    public static User login(){
        System.out.println("请输入用户名：");
        String name=scanner.next();
        System.out.println("请选择您的角色：1.普通用户。0.管理员");
        int choice=scanner.nextInt();
        if(choice==1){
            return new NormalUser(name);
        }
        return new AdminUser(name);
    }
}
